package cn.site.core.orm.persistence;

import java.util.List;

import javax.persistence.EntityManager;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.transform.ResultTransformer;

/**
 * DAO 支持类扩展
 *
 * @param <T>
 * @author ZGJ
 */
public interface BaseDao<T> {

    /**
     * 获取 EntityManager 对象
     *
     * @return
     */
    public abstract EntityManager getEntityManager();

    /**
     * 获取 Session 对象
     *
     * @return
     */
    public abstract Session getSession();

    public abstract void flush();

    public abstract void clear();

    public abstract <E> Page<E> find(Page<E> paramPage, String paramString,
                                     Object[] paramArrayOfObject);

    public abstract <E> List<E> find(String paramString,
                                     Object[] paramArrayOfObject);

    public abstract int update(String paramString, Object[] paramArrayOfObject);

    public abstract Query createQuery(String paramString,
                                      Object[] paramArrayOfObject);

    public abstract <E> Page<E> findBySql(Page<E> paramPage,
                                          String paramString, Object[] paramArrayOfObject);

    public abstract <E> Page<E> findBySql(Page<E> paramPage,
                                          String paramString, Class<?> paramClass, Object[] paramArrayOfObject);

    public abstract <E> List<E> findBySql(String paramString,
                                          Object[] paramArrayOfObject);

    public abstract <E> List<E> findBySql(String paramString,
                                          Class<?> paramClass, Object[] paramArrayOfObject);

    public abstract int updateBySql(String paramString,
                                    Object[] paramArrayOfObject);

    public abstract Query createSqlQuery(String paramString,
                                         Object[] paramArrayOfObject);

    public abstract Page<T> find(Page<T> paramPage);

    public abstract Page<T> find(Page<T> paramPage,
                                 DetachedCriteria paramDetachedCriteria);

    public abstract Page<T> find(Page<T> paramPage,
                                 DetachedCriteria paramDetachedCriteria,
                                 ResultTransformer paramResultTransformer);

    public abstract List<T> find(DetachedCriteria paramDetachedCriteria);

    public abstract List<T> find(DetachedCriteria paramDetachedCriteria,
                                 ResultTransformer paramResultTransformer);

    public abstract long count(DetachedCriteria paramDetachedCriteria);

    public abstract DetachedCriteria createDetachedCriteria(
            Criterion[] paramArrayOfCriterion);
}
